App({
  // onLaunch: function () {
  // },
  getUserInfo: function(cb) {
    var that = this
    if (this.globalData.userInfo) {
      typeof cb == "function" && cb(this.globalData.userInfo)
    } else {
      //调用登录接口
      wx.login({
        success: function(r) {
          that.globalData.userCode = r.code;
          wx.getUserInfo({
            success: function(res) {
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  setSid: function(sid) {
    this.globalData.sid = sid;
    wx.setStorageSync('sid', sid);
  },
  getSid: function() {
    var sid = this.globalData.sid;
    if (!sid) {
      sid = wx.getStorageSync('sid');
    }
    return sid;
  },
  setOpenId(openId) {
    this.globalData.openId = openId;
  },
  getOpenId() {
    return this.globalData.openId;
  },
  setUserId(userId) {
    this.globalData.userId = userId;
  },
  getUserId() {
    return this.globalData.userId;
  },
  getWinHei() {
    return this.globalData.winHei;
  },
  setWinHei(winHei) {
    this.globalData.winHei = winHei;
  },
  getWinWid() {
    return this.globalData.winWid;
  },
  setWinWid(winWid) {
    this.globalData.winWid = winWid;
  },
  getToken() {
    return this.globalData.token;
  },
  setToken(token) {
    this.globalData.token = token;
  },
  setRecommend(recommend) {
    this.globalData.recommend = recommend;
  },
  getRecommend() {
    return this.globalData.recommend;
  },
  setIsSeller(isSeller) {
    this.globalData.isSeller = isSeller;
  },
  getIsSeller() {
    return this.globalData.isSeller;
  },

  globalData: {
    isSeller:false,
    sid: '',
    openId: '',
    userId: '',
    userInfo: null,
    location: {
      lng: '',
      lat: '',
    },
    recommend: '',

    winHei: 0,
    winWid: 0,
    token: '',

    isFenxiao: '',
  },
  config: {
    apiUrl: 'https://manager.shouchadou.com',
    share: {
      title: '手插兜',
      imageUrl: '',
    }
  }
})